FROM fedora as maker

ADD ./nginx-1.21.6 /root/nginx

ADD ./zlib-1.2.12 /root/zlib

ADD ./pcre2-10.39 /root/pcre2

ADD ./openssl-openssl-3.0.2 /root/openssl

RUN yum makecache && yum install clang make automake glibc-static glibc-devel diffutils file perl perl-FindBin perl-IPC-Cmd -y

WORKDIR /root/nginx

RUN ./configure --prefix=/nginx --with-cc="clang" --with-ld-opt="-static"\
    --with-http_ssl_module --with-http_v2_module \
    --with-pcre=/root/pcre2 --with-zlib=/root/zlib --with-openssl=/root/openssl

RUN make 

RUN make install

FROM scratch

COPY --from=maker /nginx /nginx

COPY --from=maker /root/nginx/conf /defaultConf

COPY --from=maker /etc/passwd /etc/passwd

COPY --from=maker /etc/group /etc/group

EXPOSE 80

VOLUME [ "/nginx/conf", "/nginx/html" ]

ENTRYPOINT [ "/nginx/sbin/nginx", "-g", "daemon off;" ]